package com.zzedu.manager.impl;

import com.zzedu.common.utils.SecurityUtils;
import com.zzedu.domain.ZzFeedback;
import com.zzedu.manager.IZzFeedBackManager;
import com.zzedu.result.Result;
import com.zzedu.result.ResultEnum;
import com.zzedu.service.IZzFeedbackService;
import com.zzedu.stu.req.SubmitFeedBack;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class IZzFeedBackManagerImpl implements IZzFeedBackManager {


    @Autowired
    IZzFeedbackService zzFeedbackService;

    @Override
    public Result submit(SubmitFeedBack data) {
        ZzFeedback zzFeedback = new ZzFeedback();
        zzFeedback.setContent(data.getContent());
        zzFeedback.setFeedbackAcc(SecurityUtils.getLoginName());
        zzFeedback.setTitle(data.getTitle());
        zzFeedback.setFeedbackType(data.getFeedBackType());
        zzFeedback.setFeedbackSource("STU");
        zzFeedbackService.save(zzFeedback);
        Result result = new Result<>();
        result.setResultCode(ResultEnum.SUCCESS.getCode());
        result.setResultMessage(ResultEnum.SUCCESS.getDesc());
        result.setData(zzFeedback);
        return result;
    }
}
